feat: add a knob for reset stack#4813
Conversation
d9f4f57 to
0020cac
Compare
Subscribe to Label Actioncc @peterhuene DetailsThis issue or pull request has been labeled: "wasmtime:api", "wasmtime:config"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
DetailsTo modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
0020cac to
b736500
Compare
0173e8d to
d1fb240
Compare
03ea2cf to
391c309
Compare
729fb4d to
38979f8
Compare
alexcrichton
left a comment
There was a problem hiding this comment.
Thanks for this! Can you be sure to add some tests exercising this? Additionally can you update the fuzz configuration in crates/fuzzing/src/generators/config.rs to have a boolean to configure this flag?
While you're here, would you also be updating for perhaps updating the method names here? I originally thought that this wouldn't work on other platforms since it means that stacks are repeatedly called with commit_stack_pages which seems like it should error. In reality though Windows doesn't use this code path and additionally the Unix implementation of commit_stack_pages is a noop. In that case I think it's safe to remove commit_stack_pages entirely and otherwise rename decommit_stack_pages to something like reset_stack_pages_to_zero.
Actually though as I think more about this, I feel that there's a case to be made for removing this option entirely and simply not resetting stack pages back to zero. I don't think that the defense-in-depth argument holds a ton of water here because we make no attempt to reset the stack for non-async calls. If an alternate stack was always used then I think there's a case to be made for having this as an option since it would be turning off a uniformly off-by-default behavior, but otherwise as-is this option is only applicable with async support and the pooling instance allocator, both of which are already niche.
@cfallin I know in the past you've argued that this behavior should remain, so I'm curious if you still feel that way or if I could perhaps convince you of otherwise.
I think it's pretty important to keep this behavior, for a few reasons:
|
|
That sounds reasonable to me. @Duslia would you be ok implementing this new option, but flipping the defaults? Instead the option would enable the zeroing behavior that is currently the default today, and by default Wasmtime wouldn't zero stacks async stacks. |
c8e507a to
761abd5
Compare
cd101cc to
f956e73
Compare
|
I will add some tests tomorrow. |
| #[cfg(not(feature = "async"))] | ||
| let stack_size = 0; | ||
|
|
||
| let _ = self.async_stack_zeroing; |
There was a problem hiding this comment.
I think it's ok to drop this as it's always used by the snippet below
| /// deallocation will simply release the stack back to the pool. During the deallocation | ||
| /// process Wasmtime will by default reset the contents of the stack back to zero. |
There was a problem hiding this comment.
This last sentence will need an update since this PR is also changing the defaults.
4748a11 to
71fa050
Compare
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
fdb39fe to
78a1981
Compare
78a1981 to
1260c76
Compare
|
I pushed up some tweaks to the wording here but otherwise this looks good to me, thanks! |
This PR has been discussed in #4637. I add a knob for reset stack.